/* ----------------------------------------------------------------------------
* File: event_handler_impl.cpp
*
* Desc: Implementation of event handler for quiz Skype
*
* Created: 01/07/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#include "event_handler_impl.h"
#include "utils.h"

namespace QuizCore
{
	EventHandlerImpl::EventHandlerImpl(const EventHandlerParams& params)
	{
		m_Queue = params.Queue;
	}
	
	void EventHandlerImpl::OnCommand(SKYPE4COMLib::ICommand* pCommand)
	{
	}

	void EventHandlerImpl::OnReply(SKYPE4COMLib::ICommand* pCommand)
	{
	}

	void EventHandlerImpl::OnError(SKYPE4COMLib::ICommand* pCommand, LONG Number, BSTR Description)
	{
	}

	void EventHandlerImpl::OnAttachmentStatus(SKYPE4COMLib::TAttachmentStatus Status)
	{
	}

	void EventHandlerImpl::OnConnectionStatus(SKYPE4COMLib::TConnectionStatus Status)
	{
	}

	void EventHandlerImpl::OnUserStatus(SKYPE4COMLib::TUserStatus Status)
	{
	}

	void EventHandlerImpl::OnOnlineStatus(SKYPE4COMLib::IUser* pUser, SKYPE4COMLib::TOnlineStatus Status)
	{
	}

	void EventHandlerImpl::OnCallStatus(SKYPE4COMLib::ICall* pCall, SKYPE4COMLib::TCallStatus Status)
	{
	}

	void EventHandlerImpl::OnCallHistory()
	{
	}

	void EventHandlerImpl::OnMute(VARIANT_BOOL Status)
	{
	}

	void EventHandlerImpl::OnMessageStatus(SKYPE4COMLib::IChatMessage* pMessage, SKYPE4COMLib::TChatMessageStatus Status)
	{
		switch(Status)
		{
		case SKYPE4COMLib::cmsReceived:
			{
				// Process only answers from peoples
				MyOutputDebugString("QuizEventHandler: new message: %s", (char*)pMessage->GetBody());
				
				// Push message to queue
				MsgInfo info;
				info.msg = (char*)pMessage->GetBody();
				info.user = (char*)pMessage->GetFromDisplayName();
				m_Queue->push(info);
			}
			break;

		case SKYPE4COMLib::cmsRead:
			break;

		case SKYPE4COMLib::cmsSending:
			break;

		case SKYPE4COMLib::cmsSent:
			break;
		}
	}

	void EventHandlerImpl::OnMessageHistory(BSTR Username)
	{
	}
}
